<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=8">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta content="B2B电商平台" name="description"/>
	<meta content="B2B电商平台" name="keyword"/>
	
	<title>B2B电商平台.店铺商品物流信息</title>
	<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
	<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/global.css" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
	<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
	<link rel="stylesheet"	href="<%=path %>/include/sweetalert/sweetalert.css" type="text/css"></link>
	<script type="text/javascript"	src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
	<script type="text/javascript"	src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>
		<style type="text/css">
		body{
			background:#ebebeb;font-size: 14px;
			padding-left: 0px !important;
		}
		.title_div{
			height: 81px;
			padding-top: 20px;
			text-align: center;
			//border-bottom: 3px solid #e0e0e0;
			background: #fff;
		}
		.titleCss{
			height: 65px;
			width: 790px;
			margin: 0 auto;
			background: url('<%=path %>/images/postTrade/post_trade_one.png') no-repeat 0 0;
		}
		.title_2{
			background-position: 0 -200px;
		}
		.mainDiv{
			margin: 10px auto;
			width: 1190px;
		}
		.nextDiv .button2{
		    font: 20px "Microsoft YaHei", "SimHei ";
	    	line-height: 63px;
    		width: 203px;
			background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -148px -558px;
			color: #fff;
		}
		.nextDiv button {
		    font: 16px "Microsoft YaHei", "SimHei ";
		    line-height: 30px;
		    width: 60px;
		    background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -150px -578px;
		    color: #fff;
		}
	    .subDiv{
	    	margin: 30px 0px 50px 0px;
	    	height: 33px;
	    	text-align: center;
	    }
	    .nextDiv{
	    	/* width: 279px;
	    	height: 100%; */
	    	margin: 0px auto;
	    }
	    .main_div1{
	    	background:#fff; 
	    	height:48px;
	    	margin: 0px 5px 5px 0px;
	    	border-top: 4px solid #F75D5F;
	    	line-height: 48px;
	    	padding: 0px 10px;
	    }
	    .btCss{
	    	height: 22px;
    		width: 60px;
    		background: url('<%=path %>/images/postTrade/abtnBg.png');
    		float: left;
    		margin: 13px 0 0 20px;
    		font-size: 12px;    
    		line-height: 22px;
    		padding-left: 20px;
    		margin-left: 20px;
	    }
	    a {
		    color: #039;
		    text-decoration: none
	    }
	    ul,li{
	    	list-style: none;
	    }
	    .main_div1 li{
	    	float: left;
	    	font-size: 12px;
	    }
	    .saveDraftCss{
	    	float: right;
	    	border: 1px solid #cfcfcf;
	    	color:#333;
	    	line-height:28px;
	    	margin:10px 0px;
	    	padding: 0px 20px;
	    }
	    .saveDraftCss:hover {
	    	background: #ff8048;
	    	color:#fff;
	    	border: 1px solid #f67943;
	    }
	    .getDraftCss:hover {
	    	color:red;
	    }
	    .divCss_title{
	    	background: #fff;
		    height: 40px;
		    font: 18px/40px "Microsoft YaHei", "SimHei ";
		    text-indent: 10px;
		    border-bottom: 1px solid #d1d1d1;
		    color: #000;
		   
	    }
	    .tipH4{
	    	width:80px;
	    	float:left;
	    	font-weight: bold;
	    	line-height: 18px;
	    }
	    .cdyParaCss ul{
	    	width: 280px;border: 1px solid #c7c7c7;height: 22px;
	    }
	    .cdyParaCss ul li{
	    	display:none;
	    }
	    .cdyParaCss .tdL{
	    	text-align: right;width: 25%;
	    }
	    .cdyParaCss .tdR{
	    	text-align: left;padding-left: 10px;vertical-align: middle;
	    }
	    .cdyParaCss .tdR div{
	    	width:280px;border: 1px solid #c7c7c7;height: 22px;
	    }
	    .cdyParaCss .tdR input{
	    	border: 0px;padding: 0px 3px;margin-top: -15px;width: 250px;
	    }
	    .cdyParaCss .tdR s,td div s,.addPrice_css{
    	    float: right;
		    width: 21px;
		    height: 22px;
		    background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -275px -275px;
	    }
	    .cdyParaCss .tdR select{
	    	appearance:none;-moz-appearance:none;-webkit-appearance:none;
	    	width: 282px;margin: 20px 0 0 -257px;position: absolute;overflow: auto;max-height: 200px;
	    }
	    .cdyParaCss .tdR select option{
	    	heigth:20px;padding:5px 3px 0px;
	    }
	    .cdyParaCss .tdR select option:hover{
	    	background: #ebebeb;
	    }
	    .borderCss{
	    	border-top: 1px dashed #ccc;margin: 20px 80px;padding-bottom: 5px;
	    }
	    .div_title_css{
	    	border: 0px;margin: 15px 80px 10px;white-space: nowrap;
	    }
	    .div_title_css table tr td{
	    	width: 16%;
	    }
	    .div_title_css table tr td input{
	    	width: 90%;height: 22px;
	    }
	    .div_title_css p{
	    	color: #999;padding: 10px 0px 10px 83px;white-space: normal;
	    }
	    .radioCss{
	    	margin: 0px;
	    }
	    .line_color_css td{
	    	border-top: 1px solid #c7c7c7;
	    }
	    .td1{
	    	width: 130px;text-align: right;padding-right: 10px;
	    }
	    .addPrice_css{
	    	height: 11px;
		    background-position: -478px -298px;
		    margin-top: 11px;
		    margin-left: 5px;
		    float: left;
	    }
	    .img_css{
	    	padding-right: 10%;float: left;width: 14%;margin-top: 20px;
	    }
	    .add_img_div{
	     	height: 102px;
    		width: 102px;
	    	background: url('<%=path %>/images/postTrade/addIco.png') no-repeat 0px -50px;
	    }
	    td {
	    	vertical-align: middle;
	    }
	    
	</style>
	<script type="text/javascript">
		$(function(){
			initStatus();
		});
	
		//初始化物流状态
		function initStatus(){
			var orderNo = '${orderNo}';
			$.ajax({
				type:"post",
				url:'<%=path%>/logistic/queryStatus.do',
				dataType:"json",
				data:{orderNo:orderNo},
				success:function(data){
					if(data.success){
						var statusMap=data.obj;
						var status='';
						if(statusMap==''){
						 	status='';
						}else{
							status = statusMap.VIEW_CODE;
						}
						var statusName = statusMap.CODE_NAME;
						$("#orderStatus").html(statusName);
						initSelect(status);
					}
				}
			});
		}
		
		//初始化 select
		function initSelect(status){
			var viewCode = "010002001";
			_pullList(viewCode,status);
		}
		
		//select下拉列表
		function _pullList(viewCode,status){
			$.ajax({
				type:"post",
				url:'<%=path%>/postTrade/queryDirectoryInfo.do',
				dataType:"json",
				data:{viewCode:viewCode,flag:"1",viewFlag:"view"},
				success:function(data){
					if(data){			
						var arr = data.directoryList;
						var html = "";
						html += "<select id='logisticStatus' name='logisticStatus' style='width:120px; font-weight: inherit;font-style: inherit;font-size: 100%;font-family: inherit;'>";
						html += "<option value=''>请选择</option>";
						for(var i=0;i<arr.length;i++){
							var d = arr[i];
							if(d.VIEW_CODE<'010002006'&&d.VIEW_CODE>'010002003'){
								if(d.VIEW_CODE>status||(d.VIEW_CODE=='010002004'&&status<'010002006')||status==''){
									html += "<option value='"+d.VIEW_CODE+"'>"+d.CODE_NAME+"</option>";
								}
							}
						}
						html += "</select>";
						$("#status").append(html);
					}
				}
			});
		}
  	</script>
  </head>
  
  <body>
    <div id="contentDiv">
	   	<div style="margin: 0px 0px;background:#fff;font-size: 12px;padding-bottom: 5px;">
	   			<!-- <div class="divCss_title">物流信息录入</div> -->
	   			<div style="padding:20px 0px 0px 20px;">
	   				<div style="font-weight:bold;margin-left: 20px;height:20px;line-height:20px;color:#EE3B3B;">当前物流状态：<span id="orderStatus" style="padding:4px;"></span></div>
	   				<form id="logisticsForm">
	   				<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;line-height: 40px;">
	   					<tr>
		   					<td align="center" nowrap>订单编号：</td>
		   					<td>
		   						<span>${orderNo}</span>
		   						<input type="hidden" id="orderNo" name="orderNo" value="${orderNo}">
		   					</td>
		   				</tr>
		   				<tr>
		   					<td align="center">商品名称：</td>
		   					<td>
								<div style="width:90%;line-height:25px;">${productName}</div>		   					
							</td>
		   				</tr>
		   				<tr>
		   					<td align="center">物流状态：</td>
		   					<td >
		   						<div id="status"></div>
		   					</td>
		   				</tr>
	   					<tr>
	   						<td align="center">物流信息：</td>
	   						<td>
	   							<textarea id="logisticInfo" name="logisticInfo" rows="4" cols="25" style="width:65%" placeholder="请输入物流信息，不超过160个字" ></textarea>
	   						</td>
	   					</tr>
	   				</table>
	   				</form>
	   			</div>
	   			<div class="subDiv">
					<div class="nextDiv">
						<button onclick="_subLogistic()">保存</button>
						<button onclick="_closeIframe();">返回</button>
					</div>	
				</div>
	   		</div>		   		
    </div>
  </body>
  <script type="text/javascript">
  	/**
  * 功能：序列化form表单数据成Json对象
  * 1.name均是简单的一级对象
  * 2.同名的name属性，值会被序列化为数组，例如checkbox等控件
  */
	$.fn.serializeObject = function() {
	    var json = {};
	    var arrObj = this.serializeArray();
	    $.each(arrObj, function() {
	      if (json[this.name]) {
	           if (!json[this.name].push) {
	            json[this.name] = [ json[this.name] ];
	           }
	           json[this.name].push(this.value || '');
	      } else {
	           json[this.name] = this.value || '';
	      }
	    });
	    return json;
	};
	/* 校验 */
	function _valid(){
		var logisticInfo = $("#logisticInfo").val();
		var logisticStatus = $("#logisticStatus").val();
		//判空
		if(logisticStatus == ""||logisticStatus==null||logisticStatus=="undefined"){
			swal("请填写物流状态!");
			return false;
		}
		if(logisticInfo == ""||logisticInfo==null||logisticInfo=="undefined"){
			swal("请填写物流信息!");
			return false;
		}
		//判长
		if(logisticInfo.length>160){
			swal("物流信息超过160个字!");
			return false;
		}
		
		return true;
	}
		
  	/**
  	* @title： 提交物流信息
  	**/
  	function _subLogistic(){
    		if(!_valid()){
        		return;
    		}
        	var data = $("#logisticsForm").serializeObject(); 
    		$.ajax({
 	 		    type:"post",
 	 		    url:"<%=path%>/logistic/addLogisticInfo.do",
 	 		    data:data,
 	 		  	dataType:"json",
 	 		    success:function(data){
 	 	 		    var result = data;
 	 	 		    if(result == '1'){
 	 	 		    	_closeIframe();
 	 	 		    }else{
 	 	 		    	swal("服务器内部错误！");
 	 	 		    }
 	 	 		}
 	 		});
    	}
    	
    	//关闭 弹出层
    	function _closeIframe(){
    		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			parent.layer.close(index);
    	}
  </script>
</html>
